package com.framework.boc.error;

public class CommonException extends Exception implements CommonError {

    private CommonError commonError;

    /**
     * 通过通用错误构建异常
     * @param commonError
     */
    public CommonException(CommonError commonError) {
        super();
        this.commonError = commonError;
    }

    /**
     * 自定义异常信息
     * @param commonError       通用异常
     * @param errorMessage      异常信息
     */
    public CommonException(CommonError commonError, String errorMessage) {
        super();
        this.commonError = commonError;
        this.commonError.setErrorMessage(errorMessage);
    }

    @Override
    public int getErrorCode() {
        return this.commonError.getErrorCode();
    }

    @Override
    public String getErrorMessage() {
        return this.commonError.getErrorMessage();
    }

    @Override
    public void setErrorMessage(String errorMessage) {
        this.commonError.setErrorMessage(errorMessage);
    }
}
